# -*- coding: utf-8 -*-
import scrapy
from ImagesRename.items import ImagesrenameItem

class ImgsrenamespiderSpider(scrapy.Spider):
    name = 'ImgsrenameSpider'
    allowed_domains = ['lab.scrapyd.cn']
    start_urls = ['http://lab.scrapyd.cn/archives/55.html/',
                  'http://lab.scrapyd.cn/archives/57.html/']

    def parse(self, response):
        # 实例化item
        item = ImagesrenameItem()
        # 一个集合 包括多张图片
        item['imgurl'] = response.xpath("//p/img/@src").extract()
        # 取每页标题设为文件夹名字
        item['imgname'] = response.xpath("//h1[@class='post-title']/a/text()").extract_first()
        yield item

